package InputPreparer;

import java.util.ArrayList;

import AggregationMethod.AggregationMethodInterface;
import Global.ConstantVariable;
import Global.GlobalClass;
import Sampling.SamplingAbstractClass;

public class InputPreparerFactory {

	public InputPreparationMethodInterface createInputPreparer (ArrayList<Object> parametreList, SamplingAbstractClass currentSampling, GlobalClass global)
	{
		try
		{
			String name = (String)parametreList.get(0);
			
			if(name==ConstantVariable.InputPreparer_Constants.CONTENT_INPUT)
			{	
				return   new ContentPreparerClass(currentSampling, global);
			}

			if(name==ConstantVariable.InputPreparer_Constants.CONTENT_INPUT_WITH_SELECTED_FEATURES)
			{
				int[] selectedFeatures = (int[])parametreList.get(1);
				int contentType= 0;
				
				return new ContentPreparerWithSelectedFeatures(currentSampling, global, contentType,selectedFeatures);
			}
			
			if(name==ConstantVariable.InputPreparer_Constants.LINK_INPUT)
			{
				
				int edgeType= (Integer) parametreList.get(1);
				int degree= (Integer) parametreList.get(2);
				AggregationMethodInterface aggregationMethod= (AggregationMethodInterface)parametreList.get(3);  
				return new LinkPreparerClass(edgeType,degree,aggregationMethod, currentSampling, global);
			}
			
			if(name==ConstantVariable.InputPreparer_Constants.CLASSIFIER_WITH_GLOBAL_WEIGTH_INPUT)
			{
				ArrayList<ClassifierInputDataClass> classifierData= (ArrayList<ClassifierInputDataClass>) parametreList.get(1);
				return new LocalClassifierGlobalWeigthInputPreparerClass(name, classifierData, currentSampling.getGlobal());
			}
			
			if(name==ConstantVariable.InputPreparer_Constants.CLASSIFIER_WITH_LOCAL_WEIGTH_INPUT)
			{
				double contentThreshold=(Double) parametreList.get(2);
				int linkNeighborLevel =(Integer) parametreList.get(3);
				ArrayList<ClassifierInputDataClass> classifierData=(ArrayList<ClassifierInputDataClass>) parametreList.get(1);
				return new LocalClassifierLocalWeigthInputPreparerClass(name, classifierData, linkNeighborLevel, contentThreshold, currentSampling.getGlobal());
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
			System.out.println("Input Preparer can not initialize !! ");
			System.exit(0);
		}
		return null;
	}
	
}
